﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using WPFExcelReport.Helpers;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class UIGLLG : ViewBase
    { 
        
        public UIGLLG()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
         }

        public void Load()
        {
            TBMain.Clear();
            if (CART.Length < 33)
                return;
            dwData = TBMain.NewRow();
          
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwGB = dwMaster;
        }
    }
    public partial class UIGLLG 
    {
        public VGLLG TMV
        {
            get
            {
                return (VGLLG)MV;
            }
        }

        #region ==TBGB===========
        public static readonly DependencyProperty TBGBProperty = DependencyProperty.Register("TBGB",
            typeof(DataTable), typeof(UIGLLG),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTBGBChanged));
        public DataTable TBGB
        {
            get
            {
                return (DataTable)GetValue(TBGBProperty);
            }
            set
            {
                SetValue(TBGBProperty, value);
            }
        }
        private static void OnTBGBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.TBGB = (DataTable)e.NewValue;
            }
        }
        #endregion

        #region ==PARTIE===========
        public static readonly DependencyProperty PARTIEProperty = DependencyProperty.Register("PARTIE",
            typeof(string), typeof(UIGLLG),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPARTIEChanged));
        public string PARTIE
        {
            get
            {
                return (string)GetValue(PARTIEProperty);
            }
            set
            {
                SetValue(PARTIEProperty, value);
                OnPARTIEChg();
            }
        }
        private static void OnPARTIEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.PARTIE = (string)e.NewValue; 
            }
        }
        public virtual void OnPARTIEChg()
        { }
        #endregion

        #region ==MU===========
        public static readonly DependencyProperty MUProperty = DependencyProperty.Register("MU",
            typeof(string), typeof(UIGLLG),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMUChanged));
        public string MU
        {
            get
            {
                return (string)GetValue(MUProperty);
            }
            set
            {
                SetValue(MUProperty, value);
                OnMUChg();
            }
        }
        private static void OnMUChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.MU = (string)e.NewValue;
            }
        }
        public virtual void OnMUChg()
        { }
        #endregion
        #region ==CART===========
        public static readonly DependencyProperty CARTProperty = DependencyProperty.Register("CART",
            typeof(string), typeof(UIGLLG),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnCARTChanged));
        public string CART
        {
            get
            {
                return (string)GetValue(CARTProperty);
            }
            set
            {
                SetValue(CARTProperty, value);
            }
        }
        private static void OnCARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.CART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==BOX===========
        public static readonly DependencyProperty BOXProperty = DependencyProperty.Register("BOX",
            typeof(int), typeof(UIGLLG),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnBOXChanged));
        public int BOX
        {
            get
            {
                return (int)GetValue(BOXProperty);
            }
            set
            {
                SetValue(BOXProperty, value);
            }
        }
        private static void OnBOXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.BOX = (int)e.NewValue; 
            }
        }
        #endregion
        #region ==NBOX===========
        public static readonly DependencyProperty NBOXProperty = DependencyProperty.Register("NBOX",
            typeof(int), typeof(UIGLLG),
            new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnNBOXChanged));
        public int NBOX
        {
            get
            {
                return (int)GetValue(NBOXProperty);
            }
            set
            {
                SetValue(NBOXProperty, value);
            }
        }
        private static void OnNBOXChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.NBOX = (int)e.NewValue;
            }
        }
        #endregion
        #region ==QTY===========
        public static readonly DependencyProperty QTYProperty = DependencyProperty.Register("QTY",
            typeof(double), typeof(UIGLLG),
            new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnQTYChanged));
        public double QTY
        {
            get
            {
                return (double)GetValue(QTYProperty);
            }
            set
            {
                SetValue(QTYProperty, value);
            }
        }
        private static void OnQTYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                src.QTY = (double)e.NewValue; 
            }
        }
        #endregion
        #region ==dwGB===========
        public static readonly DependencyProperty dwGBProperty = DependencyProperty.Register("dwGB",
        typeof(DataRow), typeof(UIGLLG),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwGBChanged));

        public DataRow dwGB
        {
            get
            {
                return (DataRow)GetValue(dwGBProperty);
            }
            set
            {
                SetValue(dwGBProperty, value);
            }
        }
        private static void OdwGBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIGLLG;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwGB = row;
            }
        }
        #endregion

    }
}
